home *** CD-ROM | disk | FTP | other *** search
/ Champak Vol E-12 / Vol E-12.iso / games / barbie / barbi000.swf / scripts / frame_1 / DoAction.as
Text File  |  2012-05-21  |  4KB  |  156 lines

  1. function move()
  2. {
  3.    _root.nextr = _root.oldrows + _root.dirr;
  4.    _root.nextc = _root.oldcols + _root.dirc;
  5.    if(8 < _root.grid[_root.nextr][_root.nextc])
  6.    {
  7.       _root.grid[_root.oldrows][_root.oldcols] = _root.prevplace;
  8.       _root.prevplace = _root.grid[_root.nextr][_root.nextc];
  9.       _root.grid[_root.nextr][_root.nextc] = 9;
  10.       _root.oldrows = _root.nextr;
  11.       _root.oldcols = _root.nextc;
  12.       with(_root.man)
  13.       {
  14.          play();
  15.       }
  16.    }
  17.    else
  18.    {
  19.       trace("wall");
  20.       _root.reset = 0;
  21.    }
  22. }
  23. function setup(num)
  24. {
  25.    startx = 300;
  26.    starty = 150;
  27.    _root.countup = 0;
  28.    i = 0;
  29.    while(i < _root.rows)
  30.    {
  31.       _root.newstartx = _root.startx - i * 30;
  32.       _root.newstarty = _root.starty + i * 15;
  33.       k = 0;
  34.       while(k < _root.cols)
  35.       {
  36.          _root.attachMovie("square" + num,"sq" + _root.countup,_root.countup * 2);
  37.          setProperty(eval("_root.sq" + _root.countup), _X, _root.newstartx + k * 30);
  38.          setProperty(eval("_root.sq" + _root.countup), _Y, _root.newstarty + k * 15);
  39.          whatamic = _root.countup % _root.cols;
  40.          whatamir = Math.floor(_root.countup / _root.rows);
  41.          whatami = _root.grid[whatamir][whatamic];
  42.          with(eval("_root.sq" + _root.countup))
  43.          {
  44.             gotoAndStop(whatami);
  45.          }
  46.          with(_root.walls)
  47.          {
  48.             gotoAndStop(num);
  49.          }
  50.          _root.countup += 1;
  51.          k++;
  52.       }
  53.       i++;
  54.    }
  55.    _root.fadein = 1;
  56. }
  57. function direction()
  58. {
  59.    if(_root.dir == 1)
  60.    {
  61.       _root.dirc = 0;
  62.       _root.dirr = -1;
  63.       _root.reset = 0;
  64.       with(_root.man)
  65.       {
  66.          gotoAndStop("up");
  67.       }
  68.    }
  69.    if(_root.dir == 2)
  70.    {
  71.       _root.dirc = 1;
  72.       _root.dirr = 0;
  73.       _root.reset = 0;
  74.       with(_root.man)
  75.       {
  76.          gotoAndStop("right");
  77.       }
  78.    }
  79.    if(_root.dir == 3)
  80.    {
  81.       _root.dirc = 0;
  82.       _root.dirr = 1;
  83.       _root.reset = 0;
  84.       with(_root.man)
  85.       {
  86.          gotoAndStop("down");
  87.       }
  88.    }
  89.    if(_root.dir == 4)
  90.    {
  91.       _root.dirc = -1;
  92.       _root.dirr = 0;
  93.       _root.reset = 0;
  94.       with(_root.man)
  95.       {
  96.          gotoAndStop("left");
  97.       }
  98.    }
  99. }
  100. function stage1()
  101. {
  102.    _root.dir = 4;
  103.    _root.direction();
  104.    _root.prevplace = 15;
  105.    _root.r0 = "1,1,1,1,1,1,1,1,1,1,1";
  106.    _root.r1 = "1,17,17,17,17,17,17,17,17,17,1";
  107.    _root.r2 = "1,17,17,17,17,13,17,17,14,17,1";
  108.    _root.r3 = "1,17,11,17,17,17,17,17,17,17,1";
  109.    _root.r4 = "1,16,17,17,17,17,17,17,17,17,1";
  110.    _root.r5 = "1,17,17,17,17,17,17,17,17,17,1";
  111.    _root.r6 = "1,17,15,17,17,17,17,10,17,17,1";
  112.    _root.r7 = "1,17,17,17,12,17,17,17,17,17,1";
  113.    _root.r8 = "1,17,17,17,17,17,17,17,17,17,1";
  114.    _root.r9 = "1,17,17,9,17,17,17,17,17,17,1";
  115.    _root.r10 = "1,1,1,1,1,1,1,1,1,1,1";
  116.    i = 0;
  117.    while(i < rows)
  118.    {
  119.       var temp = eval("_root.r" + i);
  120.       _root.grid[i] = temp.split(",");
  121.       i++;
  122.    }
  123.    i = 0;
  124.    while(i < rows)
  125.    {
  126.       k = 0;
  127.       while(k < cols)
  128.       {
  129.          _root.grid[i][k] = Number(_root.grid[i][k]);
  130.          k++;
  131.       }
  132.       i++;
  133.    }
  134.    setup(1);
  135.    _root.man.begin();
  136. }
  137. function killme()
  138. {
  139.    trace("killme called");
  140.    with(_root.man)
  141.    {
  142.       gotoAndPlay("gareth");
  143.    }
  144. }
  145. grid = new Array();
  146. rows = 11;
  147. cols = 11;
  148. reset = 1;
  149. _root.mystage = 1;
  150. _root.countup = 0;
  151. _root.startup = 0;
  152. _root.fadein = 0;
  153. _root.fadeout = 0;
  154. totalcells = rows * cols;
  155. stop();
  156.